<%@tag pageEncoding="UTF-8"%>
<%@ attribute name="page" type="com.github.miemiedev.mybatis.paginator.domain.Paginator" required="true"%>
<%@ attribute name="isHidePagination" type="java.lang.Boolean" required="false"%>
<%@ attribute name="isShowPageLength" type="java.lang.Boolean" required="false"%>
<%@ attribute name="target" type="java.lang.String" required="false"%>
<%@ attribute name="isShowPageInfo" type="java.lang.Boolean" required="false"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<%
if(target == null || "".equals(target)){
	target = "listDiv";
}
Integer[] siders = page.getSlider();
int current = page.getPage();
int limit = page.getLimit();
request.setAttribute("siders", siders);
request.setAttribute("current", current);
request.setAttribute("limit", limit);
request.setAttribute("target", target);
%>

<% if(isShowPageInfo != null && isShowPageInfo) {%>
	<div class="dataTables_info" role="status" aria-live="polite">显示[<%= page.getStartRow()%>]到[<%= page.getEndRow()%>]条数据，总共[<%=page.getTotalCount()%>]条数据,当前第[<%=page.getPage() %>/<%=page.getTotalPages() %>]页</div>
<%} %>

<%if(isShowPageLength != null && isShowPageLength) {%>
	<div class="dataTables_length">
    	<label>显示&nbsp;<select onchange="javascript:setLimit(this.value,'${target}')" class="form-control input-sm input-xsmall input-inline">
	      	<option value="10" <c:if test="${limit == 10}">selected</c:if>>10</option>
			<option value="20" <c:if test="${limit == 20}">selected</c:if>>20</option>
			<option value="50" <c:if test="${limit == 50}">selected</c:if>>50</option>
			<option value="100" <c:if test="${limit == 100}">selected</c:if>>100</option>
     	</select>&nbsp;条数据</label>
   	</div>
<%} %>

<%if (isHidePagination == null || !isHidePagination) {%>
	<div class="dataTables_paginate paging_bootstrap_number" id="sample_1_paginate">
		<ul class="pagination" style="visibility: visible;">
			<%if(page.isFirstPage()){ %>
	   			<li class="prev disabled"><a href="#" title="First"><i class="fa fa-angle-double-left"></i></a></li>
	   		<%}else{%>
	   			<li class="prev"><a href="#" title="First" onclick="javascript:setPage(1,'${target}');"><i class="fa fa-angle-double-left"></i></a></li>
	   		<%} %>
	   		<%if(page.isHasPrePage()){ %>
	   			<li class="prev"><a href="#" title="Prev"><i class="fa fa-angle-left"></i></a></li>
	   		<%}else{%>
	   			<li class="prev disabled"><a href="#" title="Prev" onclick="javascript:setPage(${current}-1,'${target}');"><i class="fa fa-angle-left"></i></a></li>
	   		<%} %>
			<c:forEach var="i" items="${siders}">
	            <c:choose>
	                <c:when test="${i == current}">
	                	<li class="active"><a href="#">${i}</a></li>
	                </c:when>
	                <c:otherwise>
	                	<li><a href="javascript:setPage(${i},'${target}');">${i}</a></li>
	                </c:otherwise>
	            </c:choose>
	        </c:forEach>
	        <%if(page.isHasNextPage()) {%>
	   	    	<li class="next"><a href="#" title="Next" onclick="javascript:setPage(${current}+1,'${target}');"><i class="fa fa-angle-right"></i></a></li>
	   	    <%} else {%>
	   			<li class="next disabled"><a href="#" title="Next"><i class="fa fa-angle-right"></i></a></li>
	   	    <%} %>
	   	    <%if(page.isLastPage()) {%>
	        	<li class="next disabled"><a href="#" title="Last"><i class="fa fa-angle-double-right"></i></a></li>
	   		<%}else{%>
	   	    	<li class="next"><a href="#" title="Last" onclick="javascript:setPage(<%=page.getTotalPages() %>,'${target}');"><i class="fa fa-angle-double-right"></i></a></li>
	   		<%} %>
		</ul>
	</div>
<%}%>
